﻿<UserControl x:Class="Silverlight.Arcgis.MapTip.CustomClusterer"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client"
    xmlns:samples="clr-namespace:Silverlight.Arcgis.MapTip"
    xmlns:esriConverters="clr-namespace:ESRI.ArcGIS.Client.ValueConverters;assembly=ESRI.ArcGIS.Client"
    xmlns:esriSymbols="clr-namespace:ESRI.ArcGIS.Client.Symbols;assembly=ESRI.ArcGIS.Client"
    xmlns:sys="clr-namespace:System;assembly=mscorlib">
    <Grid x:Name="LayoutRoot" Background="White" >

        <Grid.Resources>
            <esriSymbols:SimpleMarkerSymbol x:Name="MediumMarkerSymbol" Color="#FF00BB00" Size="12" Style="Circle" />
            <esriConverters:DictionaryConverter x:Name="MyDictionaryConverter" />
        </Grid.Resources>

        <esri:Map x:Name="MyMap" Extent="-130,10,-70,60" >
            <esri:Map.Layers>
                <esri:ArcGISDynamicMapServiceLayer ID="StreetMapLayer"  Initialized="ArcGISDynamicMapServiceLayer_Initialized"
                    Url="{StaticResource MapUrl}"/>

                <esri:FeatureLayer ID="MyFeatureLayer"
                    Url="{StaticResource MapFeatureLayer}" 
                    Where="1=1" FeatureSymbol="{StaticResource MediumMarkerSymbol}" >
                    <esri:FeatureLayer.Clusterer>
                        <samples:SumClusterer AggregateColumn="POP1990" SymbolScale="0.001" />
                    </esri:FeatureLayer.Clusterer>
                    <esri:FeatureLayer.OutFields>
                        <sys:String>CITY_NAME</sys:String>
                        <sys:String>POP1990</sys:String>
                    </esri:FeatureLayer.OutFields>
                    <esri:FeatureLayer.MapTip>
                        <Grid Background="LightYellow">
                            <StackPanel Margin="5">
                                <TextBlock Text="{Binding Converter={StaticResource MyDictionaryConverter}, 
                                    ConverterParameter=CITY_NAME, Mode=OneWay}" FontWeight="Bold" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="Population (1990): " />
                                    <TextBlock Text="{Binding Converter={StaticResource MyDictionaryConverter},
                                        ConverterParameter=POP1990, Mode=OneWay}" />
                                </StackPanel>
                            </StackPanel>
                            <Border BorderBrush="Black" BorderThickness="1" />
                        </Grid>
                    </esri:FeatureLayer.MapTip>
                </esri:FeatureLayer>

            </esri:Map.Layers>
        </esri:Map>

        <Grid Margin="10" HorizontalAlignment="Right" VerticalAlignment="Top">
            <Border Background="#99111111" CornerRadius="3" Padding="5">
                <StackPanel Orientation="Vertical" Margin="5">
                    <TextBlock Text="Population density" Foreground="White" FontWeight="Bold" FontSize="12" Margin="3" />
                    <CheckBox Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" IsChecked="True" Content="Enable Clustering" 
                        HorizontalAlignment="Center" Foreground="White" Margin="0,0,5,0" />
                </StackPanel>
            </Border>
        </Grid>

    </Grid>
</UserControl>
